package gz.itcast.a_jdbc;

import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
import java.util.Properties;

/**
 * Created 吴海杰 on 2017/2/26.
 */
public class Demo1 {
    private String url="jdbc:mysql://localhost:3306/day0224";
    private String user="whj";
    private String password="whj";
    public void test1() throws Exception{
        Driver driver =new com.mysql.jdbc.Driver();
        Properties properties=new Properties();
        properties.setProperty("user",user);
        properties.setProperty("password",password);
        Connection connection=driver.connect(url,properties);
        System.out.println(connection);
    }



    public void test2() throws Exception{
        //Driver driver=new com.mysql.jdbc.Driver();
        Class.forName("com.mysql.jdbc.Driver");
        //DriverManager.registerDriver(driver);
        Connection connection= DriverManager.getConnection(url,user,password);
        System.out.println(connection);
    }



}
